package com.ruoyi.huoxingshi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.huoxingshi.domain.HxsVipPlans;
import com.ruoyi.huoxingshi.service.IHxsVipPlansService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员套餐Controller
 * 
 * @author huoxingshi
 * @date 2025-06-25
 */
@RestController
@RequestMapping("/huoxingshi/vipPlans")
public class HxsVipPlansController extends BaseController
{
    @Autowired
    private IHxsVipPlansService hxsVipPlansService;

    /**
     * 查询会员套餐列表
     */
    @PreAuthorize("@ss.hasPermi('huoxingshi:vipPlans:list')")
    @GetMapping("/list")
    public TableDataInfo list(HxsVipPlans hxsVipPlans)
    {
        startPage();
        List<HxsVipPlans> list = hxsVipPlansService.selectHxsVipPlansList(hxsVipPlans);
        return getDataTable(list);
    }

    /**
     * 导出会员套餐列表
     */
    @PreAuthorize("@ss.hasPermi('huoxingshi:vipPlans:export')")
    @Log(title = "会员套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HxsVipPlans hxsVipPlans)
    {
        List<HxsVipPlans> list = hxsVipPlansService.selectHxsVipPlansList(hxsVipPlans);
        ExcelUtil<HxsVipPlans> util = new ExcelUtil<HxsVipPlans>(HxsVipPlans.class);
        util.exportExcel(response, list, "会员套餐数据");
    }

    /**
     * 获取会员套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('huoxingshi:vipPlans:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hxsVipPlansService.selectHxsVipPlansById(id));
    }

    /**
     * 新增会员套餐
     */
    @PreAuthorize("@ss.hasPermi('huoxingshi:vipPlans:add')")
    @Log(title = "会员套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HxsVipPlans hxsVipPlans)
    {
        return toAjax(hxsVipPlansService.insertHxsVipPlans(hxsVipPlans));
    }

    /**
     * 修改会员套餐
     */
    @PreAuthorize("@ss.hasPermi('huoxingshi:vipPlans:edit')")
    @Log(title = "会员套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HxsVipPlans hxsVipPlans)
    {
        return toAjax(hxsVipPlansService.updateHxsVipPlans(hxsVipPlans));
    }

    /**
     * 删除会员套餐
     */
    @PreAuthorize("@ss.hasPermi('huoxingshi:vipPlans:remove')")
    @Log(title = "会员套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hxsVipPlansService.deleteHxsVipPlansByIds(ids));
    }
}
